From Cppreference
|
|
|
|
|
|
|
| template< class T > class shared_ptr;
|
| (C++11 feature)
|
|
|
|
std::shared_ptr is a smart pointer that manages an object through a pointer to it. Several shared_ptr objects can link to the same object. It is guaranteed to be destroyed when the last shared_ptr pointing to it is destroyed or reset. The object is destroyed using delete expression or a custom deleter that is supplied along the pointer to the managed object during construction.
[edit] Member types
|
|
| Member type
| Definition
|
|
|
| element_type
| T
|
[edit] Member functions
|
|
|
| constructs new shared_ptr (public member function)
|
|
|
|
| destructs the owned object if no more shared_ptrs link to it (public member function)
|
|
|
|
| assigns the shared_ptr (public member function)
|
Modifiers
|
|
|
|
| replaces the managed object (public member function)
|
|
|
|
| swaps the managed objects (public member function)
|
Observers
|
|
|
|
| returns a pointer to the managed object (public member function)
|
|
|
|
| dereferences pointer to the managed object (public member function)
|
|
|
|
| returns the number of shared_ptr objects referring to the same managed object (public member function)
|
|
|
|
| checks whether the managed object is managed only by the current shared_ptr instance (public member function)
|
|
|
|
| checks if there is associated managed object (public member function)
|
|
|
|
| checks whether the managed object precedes managed object of another shared pointer in implementation defined order, i.e. orders the managed objects (public member function)
|
[edit] Non-member functions
|
|
|
| specializes the std::swap() algorithm (function template)
|
|
|
|
| creates a shared pointer that manages a new object (function template)
|
|
|
|
| creates a shared pointer that manages a new object allocated using an allocator (function template)
|
|
|
|
| applies static_cast, dynamic_cast or const_cast to the type of the managed object (function template)
|